from flask import Blueprint
from flask_restful import Api

import os

from api.view.account import LoginView
from .test_model_api import UserResource, UserResourceWithId, DepartmentResource, DepartmentResourceWithId
from .test_model_api import StudentResource, StudentResourceWithId, CourseResource, CourseResourceWithId
from .test_model_api import CourseScoreResource, CourseScoreResourceWithId

from api.resource import register_resources

HERE = os.path.abspath(os.path.dirname(__file__))

# 注册一个登录蓝图模块，统一url前缀
blueprint_login = Blueprint('login_api', __name__, url_prefix='/api/v1')
login_rest = Api(blueprint_login)
login_rest.add_resource(LoginView, *LoginView.url_prefix)


# 注册一个测试蓝图模块，统一url前缀
blueprint_test = Blueprint("test_api", __name__, url_prefix="/api/v1/test")
test_rest = Api(blueprint_test)
register_resources(os.path.join(HERE), test_rest)

# 添加我们的视图(就是我们写的接口)
# test_rest.add_resource(UserResource, *UserResource.url_prefix)
# test_rest.add_resource(UserResourceWithId, *UserResourceWithId.url_prefix)

# test_rest.add_resource(DepartmentResource, *DepartmentResource.url_prefix)
# test_rest.add_resource(DepartmentResourceWithId, *DepartmentResourceWithId.url_prefix)

# test_rest.add_resource(StudentResource, *StudentResource.url_prefix)
# test_rest.add_resource(StudentResourceWithId, *StudentResourceWithId.url_prefix)

# test_rest.add_resource(CourseResource, *CourseResource.url_prefix)
# test_rest.add_resource(CourseResourceWithId, *CourseResourceWithId.url_prefix)

# test_rest.add_resource(CourseScoreResource, *CourseScoreResource.url_prefix)
# test_rest.add_resource(CourseScoreResourceWithId, *CourseScoreResourceWithId.url_prefix)

